package org.unisinos.gc.dao;

import java.sql.Connection;
import java.sql.SQLException;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public abstract class ConnectionManager {

	private static DataSource dataSource;
	
	static {
		try {
			InitialContext initialContext = new InitialContext();
			Context envContext = (Context) initialContext
					.lookup("java:comp/env");
			dataSource = (DataSource) envContext.lookup("jdbc/congressos");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static final Connection getConnection() throws SQLException {
		return dataSource.getConnection();	
	}
	
}
